﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WLMCoreLibrary;

namespace MWS_Main.AuthorizeFacebook
{
    /// <summary>
    /// Summary description for FacebookLogin
    /// </summary>
    public class FacebookLogin : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {

        public void ProcessRequest( HttpContext context )
        {
            
            var accessToken = context.Request["accessToken"];
            WebSiteMainConfiguration config = WebSiteMainConfiguration.GetConfig();
            dbConnector ConexionDB = new dbConnector( config.Connections[0].value );
            MiWebSiteDomain dominio = new MiWebSiteDomain( CurrentDomain.DomainName, ref ConexionDB );
            dominio.twitterAccount = accessToken.ToString();
            dominio.Save();
            CurrentDomain.Refresh();
            context.Response.Redirect( "/AuthorizeFacebook/completado.aspx" );
        }

        public bool IsReusable
        {
            get { return false; }
        }
    }
}